<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        .menu{
            display: flex;
        }
        .menu .item{
            flex: 1;
        }
    </style>
</head>

<body>
    <div id="app">
        <ul class="menu">
            <li v-for="item in  list" class="item"  @mouseover="over(item.id)" @mouseout="out">
                <span>{{item.msg}}</span>
                <ul v-show="activeIndex == item.id">
                    <li v-for="info in  item.list">
                        {{info.msg}}
                    </li>
                </ul>
            </li>
        </ul>
    </div>

</body>
<script>
    new Vue({
        el: "#app",
        data: {
            activeIndex: 0,
            list: [{ id: 1, msg: "菜单1", list: [{ id: 11, msg: "菜单1-1" }, { id: 12, msg: "菜单1-2" }] }, { id: 2, msg: "菜单2", list: [{ id: 21, msg: "菜单2-1" }, { id: 22, msg: "菜单2-2" }] }, { id: 3, msg: "菜单3", list: [{ id: 31, msg: "菜单3-1" }, { id: 32, msg: "菜单3-2" }] }]
        },
        methods: {
            over(id) {
                // this.activeIndex == id;
                this.activeIndex = id;
            },
            out(){
                this.activeIndex = 0;
            }
        }

    })

</script>

</html>